/**
 * 							RTC Defination
 * @brief	RTC Definaton
 * @author	chy.
 * @note
 * @comment	this file defines macros and functions used by common time module!
 */

#ifndef	_K_DRIV_RTC_S3C2440_C_
#define	_K_DRIV_RTC_S3C2440_C_

#include "k_rtc_s3c2440.h"

/**
 * @BRIEF	:	Initialize RTC
 * @PARAM	:	void
 * @RETURN	:	void
 * @NOTE	:	The hard rtc is different in different platform.
 */
void k_driv_s3c2440_rtc_init(void)
{
	// do nothing about LOCKTIME PLL registers.In fact, I don't know how to control it.

	// set UPLL, after this set MPLL, I don't know why s3c2440 assume this.
	// 48MHz fixed!
	R_UPLLCON = (0x38 << 12) | (2 << 4 ) | 2;
	// set MPLL, we use 405MHz, MPLL will support FCKL,HCKL and PCKL.
	R_MPLLCON = (0x7f << 12) | (2 << 4 ) | 1;

	// R_CLKCON we use defualt current.ai......
	// CLKSLOW we use default current.ai.....
	// all others we use defualt! ai......

	// set CLKDIVN, we don;t need 405MHz for PCKL.we use 1:3:6, so, PCKL is about 67MHz
	R_CLKDIVN = 6;
}

/**
 * @BRIEF	:	Set RTC Value
 * @PARAM	:	time time value
 * @RETURN	:	0 failed, other success
 * @NOTE	:	this function will igore week field in K_Time structure
 */
unsigned int k_driv_s3c2440_rtc_set(K_Time *time)
{
	return 0;
}

#endif	/* _K_DRIV_RTC_S3C2440_C_ */